import  java.util.Scanner;
class Worker {
    private String name;//姓名
    private double rate;//小时工资
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    public double getRate() {
        return rate;
    }
    public void setRate(double rate) {
        this.rate = rate;
    }
    public Worker(String name,double rate) {
        this.name=name;
        this.rate=rate;
    }
    public double pay(int hour) {
        return 0;
    }
}
class HourlyWorker extends Worker{

    public HourlyWorker(String name, double rate) {
        super(name, rate);
    }

    public double pay(int hour) {
        if (hour <= 40){
            return getRate()*hour;
        } else{
            return (hour - 40)*2*getRate() + 40*getRate();
        }
    }
}
class SalariedWorker extends Worker{
    public SalariedWorker(String name, double rate) {
        super(name, rate);
    }

    public double pay(int hour) {
        return 40*getRate();
    }
    public double pay() {
        return 40*getRate();
    }
}